﻿<%@ WebHandler Language="C#" Class="SizeMate_GetAll" %>

using System;
using System.Web;
using System.Text;
using Newtonsoft.Json; 
using System.Collections.Generic;

public class SizeMate_GetAll : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
    
    public void ProcessRequest (HttpContext context) {
 //检验是否登录
        OTS.Common.PageSuccess page = new OTS.Common.PageSuccess();
        if (!OTS.BaseLogin.validataModule(context, (int)OTS.enumSysRight.SizeManager))
        {
            context.Response.ContentType = "text/json";
            context.Response.Write("非法操作");
            return;
        }
        OTS.BLL.ProductSizeBLL bll = new OTS.BLL.ProductSizeBLL();

        List<OTS.Model.size_material> list = bll.GetSizeMatList();
        OTS.Model.size_material model;
        StringBuilder sb = new StringBuilder();
        sb.Append("[");
        for (int i = 0; i < list.Count; i++)
        {
            model = list[i];
            sb.Append("{\"sizeMatId\":" + model.sizeMatID + ",\"sizeUnit\":\"" + model.sizeUnit + "\",\"sizeMatName\":\"" + model.sizeMatName + "\"},");
            
        }
        string str = sb.ToString();
        if(str.EndsWith(","))
            str = str.Substring(0,str.Length-1);
        str += "]";
        
        context.Response.ContentType = "text/json";
        context.Response.Write(str);
         
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}